home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 October: Mac OS SDK / Dev.CD Oct 96 SDK / Dev.CD Oct 96 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / Draw / Sources / DrawSel.h < prev    next >
Encoding:
Text File  |  1996-08-16  |  7.1 KB  |  225 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                DrawSel.h
  4. //    Release Version:    $ ODF 1 $
  5. //
  6. //    Author:                Henri Lamiraux
  7. //
  8. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  9. //
  10. //========================================================================================
  11.  
  12. #ifndef DRAWSEL_H
  13. #define DRAWSEL_H
  14.  
  15. // ----- Part Layer -----
  16.  
  17. #ifndef FWSELECT_H
  18. #include "FWSelect.h"
  19. #endif
  20.  
  21. // ----- OS Layer -----
  22.  
  23. #ifndef FWRECT_H
  24. #include "FWRect.h"
  25. #endif
  26.  
  27. #ifndef FWRECSHP_H
  28. #include "FWRecShp.h"
  29. #endif
  30.  
  31. //========================================================================================
  32. //    Forward Declarations
  33. //========================================================================================
  34.  
  35. class FW_CGraphicContext;
  36. class FW_CMouseEvent;
  37.  
  38. class CDrawPart;
  39. class CDrawFrame;
  40. class CSelectionIterator;
  41. class CDrawSelection;
  42. class CBaseShape;
  43.  
  44. class CDrawContent;
  45. class CDrawSelectionContent;
  46.  
  47. //========================================================================================
  48. //    class CDrawSelection
  49. //========================================================================================
  50.  
  51. class CDrawSelection : public FW_CSelection
  52. {
  53. //----------------------------------------------------------------------------------------
  54. //    Initialization/Destruction
  55. //
  56. public:
  57.     FW_DECLARE_AUTO(CDrawSelection)
  58.  
  59.     CDrawSelection(Environment* ev, CDrawPart* drawPart);
  60.     virtual         ~CDrawSelection();
  61.     
  62. //----------------------------------------------------------------------------------------
  63. //    Inherited API
  64. //
  65. public:
  66.     virtual void        CloseSelection(Environment* ev);
  67.     virtual void        SelectAll(Environment* ev);
  68.     virtual FW_Boolean    IsEmpty(Environment* ev) const;
  69.     virtual void        ClearSelection(Environment* ev);
  70.     
  71.     virtual FW_CContent* GetSelectedContent(Environment* ev);
  72.     
  73.     virtual ODShape*    CreateSelectionShape(Environment* ev, ODFacet* facet, FW_CFrame* frame) const;
  74.     virtual ODShape*    CreateSelectionOutline(Environment* ev, ODFacet* facet, FW_CFrame* frame) const;
  75.     
  76.     virtual FW_Boolean    CanPasteAsLink(Environment* ev, ODPasteAsMergeSetting& setting, ODStorageUnit* su);
  77.     virtual FW_Boolean    IsSelectionLinkable(Environment* ev);
  78.     
  79.     virtual FW_Boolean    IsMouseInDraggableItem(Environment* ev, 
  80.                             FW_CFrame* frame,
  81.                             const FW_CMouseEvent& theMouseEvent, 
  82.                             FW_Boolean inBackground);
  83.  
  84.     virtual void        UpdateSelectionOnMouseDown(Environment* ev, 
  85.                             const FW_CMouseEvent& mouseEvent,
  86.                             ODFacet* embeddedFacet,
  87.                             FW_Boolean inEmbeddedFrameBorder,
  88.                             FW_Boolean inBackground);
  89.     
  90. //----------------------------------------------------------------------------------------
  91. //    New API
  92. //
  93. public:
  94.     CBaseShape*     WhichHandle(Environment* ev, FW_CGraphicContext& gc, const FW_CPoint& mouse, short& whichHandle) const;
  95.     
  96.     void            RenderSelectionHandles(Environment* ev, FW_CGraphicContext& gc);
  97.     void            RenderHandles(Environment* ev, CBaseShape* shape);
  98.     void            RenderAllHandles(Environment* ev, FW_CFrame* frame);
  99.     
  100.     void            AddToSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  101.     void            RemoveFromSelection(Environment* ev, CBaseShape* theShape, FW_Boolean renderHandles);
  102.  
  103.     void            OffsetSelection(Environment* ev, FW_Fixed xDelta, FW_Fixed yDelta);
  104.  
  105.     FW_Boolean        Resize(Environment* ev, const FW_CMouseEvent& theMouseEvent);    
  106.  
  107.     void            SelectWithRectangle(Environment* ev, const FW_CMouseEvent& theMouseEvent);
  108.  
  109.     FW_Boolean        GetSelectionPenSize(Environment* ev, FW_Fixed& penSize);
  110.  
  111.     FW_CPoint        CenterSelection(Environment* ev, FW_CFrame* scopeFrame);
  112.     
  113.     unsigned long    Count() const;
  114.     
  115.     // ----- Frozen state -----
  116.     FW_Boolean        HasFrozen() const;
  117.     FW_Boolean        HasNotFrozen() const;
  118.     void            SetFrozen(Environment* ev, FW_Boolean state);
  119.     
  120.     ODShape*        GetUpdateShape() const;
  121.     void            GetDragRect(FW_CRect& dragRect) const;
  122.  
  123.     // ----- Anchor Shape -----
  124.     CBaseShape*        GetAnchorShape() const;
  125.     void            SetAnchorShape(CBaseShape* shape);
  126.  
  127.  
  128.     // ----- Linking -----
  129.     void            SelectionChanged(Environment* ev);
  130.     void            DeleteSelection(Environment* ev);
  131.     FW_Boolean        IsOKtoEdit(Environment* ev);
  132.  
  133.     void            CalcCache(Environment* ev);
  134.  
  135. private:
  136.     
  137.     void            DoAdd(Environment* ev, CBaseShape *shape);
  138.     void            DoRemove(Environment* ev, CBaseShape *shape);
  139.         
  140.     FW_Boolean        IsShapeInLinkDestination(Environment* ev);
  141.  
  142. public:
  143.     void            ShapeAdded(Environment* ev, CBaseShape* shape);
  144.     void            SelectContent(Environment* ev, CDrawContent* content);
  145.     CDrawContent*    GetDrawContent(Environment* ev);
  146.  
  147. //----------------------------------------------------------------------------------------
  148. //    Data Members
  149. //
  150. private:
  151.     CDrawPart*            fDrawPart;
  152.     FW_CRect            fDragRect;
  153.     ODShape*            fUpdateShape;
  154.     unsigned short        fFrozenCount;
  155.     unsigned long        fCount;
  156.     CBaseShape*            fAnchorShape;
  157.     short                fClickedHandle;
  158.     
  159.     CDrawSelectionContent*    fSelectionContent;
  160.     
  161.     FW_CRectShape        fWorkingHandle;
  162.     CDrawSelectionContent*    fDraggedContent;
  163. };
  164.  
  165. //========================================================================================
  166. //    CDrawSelection Inlines
  167. //========================================================================================
  168.  
  169. //----------------------------------------------------------------------------------------
  170. //    CDrawSelection::GetUpdateShape
  171. //----------------------------------------------------------------------------------------
  172. inline ODShape* CDrawSelection::GetUpdateShape() const
  173. {        
  174.     return fUpdateShape;
  175. }
  176.  
  177. //----------------------------------------------------------------------------------------
  178. //    CDrawSelection::GetDragRect
  179. //----------------------------------------------------------------------------------------
  180. inline void CDrawSelection::GetDragRect(FW_CRect& dragRect) const
  181. {        
  182.     dragRect = fDragRect;
  183. }
  184.  
  185. //----------------------------------------------------------------------------------------
  186. //    CDrawSelection::HasFrozen
  187. //----------------------------------------------------------------------------------------
  188. inline FW_Boolean CDrawSelection::HasFrozen() const
  189. {
  190.     return fFrozenCount != 0;
  191. }
  192.  
  193. //----------------------------------------------------------------------------------------
  194. //    CDrawSelection::HasNotFrozen
  195. //----------------------------------------------------------------------------------------
  196. inline FW_Boolean CDrawSelection::HasNotFrozen() const
  197. {
  198.     return fCount != 0 && fFrozenCount != fCount;
  199. }
  200.  
  201. //----------------------------------------------------------------------------------------
  202. //    CDrawSelection::Count
  203. //----------------------------------------------------------------------------------------
  204. inline unsigned long CDrawSelection::Count() const
  205. {
  206.     return fCount;
  207. }
  208.  
  209. //----------------------------------------------------------------------------------------
  210. //    CDrawSelection::GetAnchorShape
  211. //----------------------------------------------------------------------------------------
  212. inline CBaseShape* CDrawSelection::GetAnchorShape() const
  213. {
  214.     return fAnchorShape;
  215. }
  216.  
  217. //----------------------------------------------------------------------------------------
  218. //    CDrawSelection::SetAnchorShape
  219. //----------------------------------------------------------------------------------------
  220. inline void CDrawSelection::SetAnchorShape(CBaseShape* shape)
  221. {
  222.     fAnchorShape = shape;
  223. }
  224.  
  225. #endif